# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

# Initial PKGBUILD from AUR.
# Old Maintainer: Fabio 'Lolix' Loli <fabio.loli@disroot.org>
# Old Contributor: Zen Wen <zen.8841@gmail.com>
# Old Contributor: Felix Yan <felixonmars@archlinux.org>
# Old Contributor: Antonio Rojas <arojas@archlinux.org>
# Old Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=qt5-webkit
_pkgver=5.212.0-alpha4
_basever=5.15.3
pkgver=${_pkgver/-/}
pkgrel=23
pkgdesc='Classes for a WebKit2 based implementation and a new QML API.'
arch=('x86_64' 'aarch64')
url='https://github.com/qtwebkit/qtwebkit'
license=('LGPL-2.1-only')
source=("https://github.com/qtwebkit/qtwebkit/releases/download/qtwebkit-$_pkgver/qtwebkit-$_pkgver.tar.xz"
        "https://src.fedoraproject.org/rpms/qt5-qtwebkit/raw/rawhide/f/qtwebkit-cstdint.patch"
        "https://src.fedoraproject.org/rpms/qt5-qtwebkit/raw/rawhide/f/qtwebkit-fix-build-gcc14.patch"
         https://src.fedoraproject.org/rpms/qt5-qtwebkit/raw/rawhide/f/webkit-offlineasm-warnings-ruby27.patch
        "qt5-webkit-icu75.patch::https://github.com/qtwebkit/qtwebkit/commit/756e1c8f23dc2720471298281c421c0076d02df8.patch"
        'qt5-webkit-python-3.9.patch'
        'qt5-webkit-bison-3.7.patch'
        'qt5-webkit-icu76.patch'
        'qt5-webkit-icu68.patch'
        'qt5-webkit-glib-2.68.patch')
depends=('qt5-location' 'qt5-sensors' 'qt5-webchannel' 'libwebp' 'glibc' 'glib2'
         'libxcomposite' 'gst-plugins-base' 'hyphen' 'woff2' 'gcc-libs' 'zlib'
         'libx11' 'sqlite' 'gst-plugins-base-libs' 'libjpeg-turbo' 'icu'
         'libpng' 'gstreamer' 'libxml2' 'qt5-base' 'qt5-declarative'
         'libicuuc.so' 'libicui18n.so')
makedepends=('cmake' 'ruby' 'ruby-erb' 'gperf' 'python' 'qt5-doc' 'qt5-tools')
optdepends=('gst-plugins-good: Webm codec support')
options=(!lto)
sha512sums=('33f11270bd030599beff9c1983a6c5ff2d61f407cc8a6825f7f405d46f9184c720fc7f60c7359f08f828db96a2170092875066a0d5c0a21ff09bc48a2603fbf6'
            '82388c5b95dea56e508780eb4386f685e086a476c4176a90773ccc4c87aae644455cc9e636c75e68d7552f80f4c83a094db7291bd76969029e8c35646506ff94'
            '1d2ff7e5e0bab4670d24741237d5d4f4a9c3c072245e7437e62e3534c192107f32b321d60ef688d6456f7d4af98a7f7722f75fd1f5cdf0213491cb0bbba9c954'
            '1431c6329fb9ef86dbe929a4002881f6a511aa8a2be684a7c96ea7ea48af53b4f0d96bd8e8367289080bed674ba35cab002747cf3820a6831e60f7ab7a53d3cc'
            '8b2a23a51a1463893ab97904f385da6744f2619d46cb011795394030de5a6647b0a39b5837ee198fd3d2804530bb98ba346abbc2a67f31bbec2092930f527a90'
            'e4d4d4abfb8f2e9913c2f5cb7b3a73d5c613a8e8ced66ae1a7789faaa83a2bdf89ff29955d7e9b7bd7a0935ca2ddcad796cf371882e2bb38b4e69c1d528cfe75'
            'd90e3bd03090d468f6d73bcee949593a9266de8c5d29f2879c53efa757e7be449db16eb7a563c6279ed2554e549f2dc6321a40cf855d6290e5bdded8f18a90e4'
            'af1c426f92722cee124c0a0d3c7b6d036a50036d02d9e4ba5524206a617ab404728aeb02ac0d5de23ac1181fff14ed24dc8fe05b470eb37475829dfd4f0a7a70'
            'c4714b40d9b516698490cc3f587f7fefe8097545a2310e144be1dfa39549ad056bf7bd67f5f89334e54c3a9bb95136876a62d0a392991a872030c4dff0d7c820'
            'f8a49e24023431ac37cff2b5bdf6f88d632021eb777668404956a4c6e4f8744f256205093dc5077325a33ec2a050b6e159dcf5d8cf3c1dda7d26ec0b37db95c3')

prepare() {
  cd "qtwebkit-$_pkgver"

  patch -p0 -i ../qt5-webkit-icu68.patch # Fix build with ICU 68.x
  patch -p1 -i ../qt5-webkit-glib-2.68.patch # https://github.com/qtwebkit/qtwebkit/issues/1057
  patch -p1 -i ../qt5-webkit-python-3.9.patch # Fix build with python 3.9
  patch -p1 -i ../qt5-webkit-bison-3.7.patch # Fix build with bison 3.7
  patch -p1 -i ../qtwebkit-cstdint.patch # gcc 11.1
  patch -p1 -i ../qtwebkit-fix-build-gcc14.patch # GCC 14.1
  patch -p1 -i ../qt5-webkit-icu75.patch
  patch -p1 -i ../qt5-webkit-icu76.patch

  #patch -Np1 -i ../qtwebkit-ruby3.2.patch
  #echo "Done patch for Ruby 3.2"

  patch -Np1 -i ../webkit-offlineasm-warnings-ruby27.patch
  echo "Done patch for Ruby 3.2"
}

build() {
  cmake -B build -S "qtwebkit-$_pkgver" -Wno-dev \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_FLAGS="${CXXFLAGS} -DNDEBUG" \
    -DPORT=Qt \
    -DUSE_LD_GOLD=OFF \
    -DENABLE_XSLT=OFF \
    -DENABLE_TOOLS=OFF
  cmake --build build

# disabling XSLT to build https://github.com/qtwebkit/qtwebkit/issues/1097
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}

